module.exports = app => {

  var router = require("express").Router();
  const errorInfo = require("../controllers/errorInfo.controller.js");



  router.use("/report", (req, res) => {
    const logs = typeof req.body === 'object' ? req.body : JSON.parse(req.body);
    const reportArray = JSON.parse(req.body)
    if (reportArray.length) {
      reportArray.forEach(async (item)=>{
        const errorEntity = JSON.parse(item)
        try {
          const createResult = await errorInfo.create(req, res, errorEntity)
          console.log("ssss", createResult)
        } catch (err) {
          console.log(err)
        }
      })


      

    }
  });
  
  app.use('/api/error', router);
};
